home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_basi / qbsvga.zip / SIM.BAS < prev    next >
BASIC Source File  |  1996-08-13  |  5KB  |  176 lines

  1. '
  2. '  This is a simple routine that may aid in seeing how to use the QBSVGA
  3. ' routines and where to put REGTYPE.INC.  If you go to compile and link
  4. ' it, use QB.LIB (in addition to whatever other libraries you would
  5. ' normally use).  This applies anytime you use the QBSVGA routines.
  6. ' Similarly, if you're going to use these routines from within the QB
  7. ' IDE, run QB with the "/L" command-line option.
  8. '
  9. '  Put the contents of REGTYPE.INC here.
  10. '
  11.     DIM CLA AS LONG,Q AS LONG
  12.     CALL BSCREEN(15!,7!,0!,0!)
  13.     CALL BLINE(10!,10!,790!,590!,14!,"BF")
  14.     CALL BCIRCLE(400!,300!,290!,13!,0!,0!,1!)
  15.     CALL BCIRCLE(400!,300!,150!,12!,0!,1.57!,1!)
  16.     S=3.141593
  17.     E=3*3.141593/2
  18.     CALL BCIRCLE(400!,300!,150!,11!,S,E,1!)
  19.     CALL BLINE(30!,30!,30!,350!,15!,"L")
  20.     CALL BCOLOR(12!)
  21. '
  22. '  A negative number input to any of the QBSVGA routines for the color
  23. ' will be reset to the default color defined in the call to BSCREEN
  24. ' (or COLOR).  (An exception to this is BVIEW; it uses color 0 in this
  25. ' situation.)
  26. '
  27.     CALL BLINE(0!,0!,799!,599!,-1!,"L")
  28.     CALL BCOLOR(9!)
  29.     CALL BLOCATE(30!,10!)
  30.     CALL BPRINT("This is an example.")
  31.     PCOLOR=BPOINT(799!,599!)
  32.     CALL BLOCATE(3!,3!)
  33.     A$="Color of pixel at (800,600) is "+LTRIM$(RTRIM$(STR$(PCOLOR)))+".;"
  34.     CALL BPRINT(A$)
  35.     CALL BPRINT("    (Wait...)")
  36.     RX=799
  37.     RY=599
  38.     CALL BLINE(0!,0!,RX,RY,10!,"B")
  39.     SLEEP 5
  40. '
  41. '  Before putting video mode in 640 x 480 x 256 state, make QB *think*
  42. ' that screen is in mode 13 so later use of palette command works.
  43. '
  44.     SCREEN 13
  45.     CALL BSCREEN(14!,6!,0!,0!)
  46.     CALL BLOCATE(1!,3!)
  47.     CALL BPRINT("Now I am going to use a graphics viewport;")
  48.     CALL BPRINT(" in a different screen mode.")
  49.     CALL BPRINT(" ")
  50.     CALL BPRINT("(Wait...)")
  51.     CALL BVIEW(40!,60!,230!,250!,0!,7!)
  52.     CALL BCIRCLE(100!,120!,40!,7!,0!,0!,2!)
  53. '
  54. '  Paint inside of circle.
  55. '
  56.     CALL BPAINT(100!,120!,11!,-1!)
  57. '
  58. '  Paint top, bottom, and righthand portions of exterior of circle.
  59. '
  60.     CALL BPAINT(141!,120!,13!,-1!)
  61. '
  62. '  Paint remaining portion of circle exterior.
  63. '
  64.     CALL BPAINT(59!,120!,13!,-1!)
  65. '
  66. '  Demonstrate how QBSVGA's BGET and BPUT statements work.
  67. '
  68.     DIM PICT(1 TO 9122) AS LONG
  69. '
  70. '  Get memory location of PICT array and store picture there.
  71. '
  72.     SM=VARSEG(PICT(1)) : OS=VARPTR(PICT(1))
  73.     CALL BGET(0!,0!,190!,190!,SM,OS)
  74.     CALL BCLS(0!)
  75.     A$="I have saved that last picture in an array."
  76.     CALL BPRINT(A$)
  77.     A$="Press a key and I'll show it to you in a different location."
  78.     CALL BPRINT(A$)
  79.     CALL BPRINT(" ")
  80.     A$="(The location isn't that different; it will still be on your screen.)"
  81.     CALL BPRINT(A$)
  82. 10 IF INKEY$="" THEN GOTO 10
  83.     CALL BCLS(0!)
  84.     CALL BPUT(0!,0!,SM,OS,"PSET")
  85.     CALL BLOCATE(14!,10!)
  86.     CALL BPRINT("Wait...")
  87.     SLEEP 5
  88.     CALL BCLS(0!)
  89.     CALL BLOCATE(1!,10!)
  90.     A$="Now I'm going to try to print 256 colors in that last graphics mode."
  91.     CALL BPRINT(A$)
  92.     CALL BLOCATE(3!,1!)
  93.     C=0
  94.     FOR I=33 TO 126
  95.     CALL BCOLOR(C)
  96.     CALL BPRINT(CHR$(I)+";")
  97.     C=C+1
  98.     NEXT I
  99.     FOR I=33 TO 126
  100.     CALL BCOLOR(C)
  101.     CALL BPRINT(CHR$(I)+";")
  102.     C=C+1
  103.     NEXT I
  104.     FOR I=33 TO 100
  105.     CALL BCOLOR(C)
  106.     CALL BPRINT(CHR$(I)+";")
  107.     C=C+1
  108.     NEXT I
  109.     CALL BPRINT(" ")
  110.     CALL BCOLOR(7!)
  111.     CALL BPRINT(" ")
  112.     CALL BPRINT(" ")
  113.     CALL BPRINT("Now I'm going to do the same thing ;")
  114.     CALL BPRINT("but in a more graphical manner.")
  115.     CALL BPRINT(" ")
  116.     CALL BPRINT(" ")
  117. '
  118. '  Get current row and make at least approximate conversion to pixel
  119. ' coordinates.
  120. '
  121.     DUMMY=BPOS(ROW)
  122.     ROW=ROW*16
  123.     FOR I=0 TO 511 STEP 2
  124.     C=INT(I/2)
  125.     CALL BLINE(I,ROW,I+1,ROW+15,C,"BF")
  126.     NEXT I
  127.     CALL BLOCATE(ROW/16+4,1!)
  128.     CALL BPRINT("Press a key to see color palette change;")
  129.     CALL BPRINT("(and then press key to quit).")
  130. 260 IF INKEY$="" THEN GOTO 260
  131. '
  132. '  The following code demonstrates that QB's PALETTE command works with
  133. ' 256-color SVGA modes.  To make this work, QB must think it's in SCREEN
  134. ' 13.  Even though the video state was changed to an SVGA mode, above,
  135. ' after using the SCREEN 13 statement, QB still thinks it's in the normal
  136. ' VGA mode; it has no idea that it's been duped.  The question then is one
  137. ' of whether or not QB'S PALETTE statement has any affect on SVGA modes.
  138. ' The answer is yes!
  139. '
  140. '  First 64 colors are gray-scales.
  141. '
  142.     FOR I=0 TO 127 STEP 2
  143.     Q=CLNG(I/2) : B=CSNG(Q)
  144.     CLA=65536&*Q+256&*Q+Q
  145.     PALETTE B,CLA
  146.     NEXT I
  147. '
  148. '  Next 64 colors add red to an otherwise 0 gray-scale.
  149. '
  150.     FOR I=128 TO 255 STEP 2
  151.     Q=CLNG(I/2)-64& : B=CSNG(Q)+64
  152.     PALETTE B,Q
  153.     NEXT I
  154. '
  155. '  Next 64 colors add green to a maximal intensity red attribute.
  156. '
  157.     FOR I=256 TO 383 STEP 2
  158.     Q=CLNG(I/2)-128& : B=CSNG(Q)+128
  159.     CLA=256&*Q+63&
  160.     PALETTE B,CLA
  161.     NEXT I
  162. '
  163. '  Final 64 colors add blue to a maximal intensity red/green attribute.
  164. '
  165.     FOR I=384 TO 511 STEP 2
  166.     Q=CLNG(I/2)-192& : B=CSNG(Q)+192
  167.     CLA=65536&*Q+16191&
  168.     PALETTE B,CLA
  169.     NEXT I
  170. 270 IF INKEY$="" THEN GOTO 270
  171.     PALETTE
  172.     CALL BSCREEN(0!,7!,0!,0!)
  173.     END
  174. '
  175. '  Put the contents of QBSVGA.BAS here.
  176.